Skip to content

fix: use active product version [APIAPEX-2731]#83

Closed
DKVON-prog wants to merge 6 commits into
mainfrom
fix/use-active-product-version
Closed

fix: use active product version [APIAPEX-2731]#83
DKVON-prog wants to merge 6 commits into
mainfrom
fix/use-active-product-version

Conversation

@DKVON-prog

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings May 19, 2026 07:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes the vcr init flow so that it selects a product template's currently active (live) version instead of the most recently created ProductVersion. Previously, picking the newest version by created_at could surface a draft/non-live version, breaking template downloads. The datastore method (and its consumers/mocks/tests) is renamed accordingly.

Changes:

  • Rename GetLatestProductVersionByIDGetActiveProductVersionByID across the datastore client, factory interface, mocks, and call site in vcr/init, and update the corresponding user-facing spinner/error messages.
  • Reimplement the lookup as two sequential GraphQL queries: fetch the product's active_version_id via Products_by_pk, then resolve that version via ProductVersions_by_pk.
  • Expand unit tests in init_test.go and datastore_test.go to cover the new flow, including missing product, empty active_version_id, missing version row, and a regression case ensuring drafts are not returned.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/api/datastore.go Replaces the latest-version GraphQL query with a two-step active-version lookup and renames associated types/method.
pkg/api/datastore_test.go Reworks the test harness to feed sequenced mock responses and adds new-failure / regression cases.
pkg/cmdutil/factory.go Renames the method on DatastoreInterface.
testutil/mocks/factory.go Regenerated mock reflecting the renamed method.
vcr/init/init.go Calls the renamed method and updates spinner / wrapped-error wording.
vcr/init/init_test.go Renames mock fields and adds an "active version not found" test case.
Files not reviewed (1)
  • testutil/mocks/factory.go: Language not supported

Comment thread pkg/api/datastore.go
Comment on lines +379 to 401
const getVersionQuery = `
query MyQuery ($id: uuid!) {
ProductVersions_by_pk(id: $id) {
id
}
}
`
activeVersionID := resp.Data.Product.ActiveVersionID
versionReq := GQLRequest{
Query: getVersionQuery,
Variables: getActiveProductVersionByIDParams{ID: activeVersionID},
}
var versionResp getProductVersionByIDResponse
if err := ds.gqlClient.Do(ctx, versionReq, &versionResp); err != nil {
return ProductVersion{}, err
}
if versionResp.Data.ProductVersion == nil || versionResp.Data.ProductVersion.ID == "" {
return ProductVersion{}, ErrNotFound
}

return *versionResp.Data.ProductVersion, nil
}

@DKVON-prog DKVON-prog closed this May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants